package com.hancher.gamelife2.function;


import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.hancher.common.rv.BaseVBAdapter;
import com.hancher.common.rv.PageRecyclerViewManager;
import com.hancher.common.rv.SubRecyclerViewListener;
import com.hancher.gamelife2.databinding.ItemHomeBinding;

import java.util.List;

import lombok.Data;

public class FunctionAdapter extends BaseVBAdapter<ItemHomeBinding, FunctionAdapter.FunctionItem> {
    SubRecyclerViewListener listener;

    public FunctionAdapter(SubRecyclerViewListener listener) {
        this.listener = listener;
    }

    @Override
    protected ItemHomeBinding createViewBinding(LayoutInflater from, ViewGroup viewGroup) {
        return ItemHomeBinding.inflate(from, viewGroup, false);
    }

    @Override
    protected void convertItem(ItemHomeBinding binding, int position, FunctionItem item) {
        binding.txtTitle.setText(item.getTitle());
        PageRecyclerViewManager<Function2Adapter.Function2Item> prvm = new PageRecyclerViewManager<Function2Adapter.Function2Item>()
                .setContext(getContext())
                .setRecyclerView(binding.recyclerview)
                .setOnItemClickListener((baseQuickAdapter, view, i) -> listener.onClickSubListItemListener(position, i))
                .setAdapter(new Function2Adapter())
                .setCol(5)
                .init();
        prvm.freshData(item.getData());
    }

    @Data
    public static class FunctionItem {
        private String title;
        private List<Function2Adapter.Function2Item> data;
    }
}
